<?php
$params = array_merge(
    require(__DIR__ . '/../../common/config/params.php'),
    require(__DIR__ . '/../../common/config/params-local.php'),
    require(__DIR__ . '/params.php'),
    require(__DIR__ . '/params-local.php')
);

return [
    'id' => 'app-backend',
    'basePath' => dirname(__DIR__),
    'controllerNamespace' => 'api\controllers',
    'bootstrap' => ['log'],
    'modules' => [],
    'components' => [

        'response' => [
            'class' => 'yii\web\Response',
            'on beforeSend' => function ($event) {
                $response = $event->sender;
                if ($response->data == null) {
                    $response->data = [
                        'code' => $response->data['status'],
                        'message' => $response->data['message'],
                        'date' => [],
                    ];
                    $response->statusCode = 200;
                }
            },
        ],


        'request' => [
            'csrfParam' => '_csrf-backend',
            'parsers' => [
                'application/json' => 'yii\web\JsonParser',
                'text/json' => 'yii\web\JsonParser',
            ]

        ],
        'user' => [
            'identityClass' => 'api\models\User',
            'enableAutoLogin' => true,
            'enableSession'=>false,
        ],
        'session' => [
            // this is the name of the session cookie used for login on the backend
            'name' => 'advanced-backend',
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],


        'urlManager' => [
            'enablePrettyUrl' => true,
            'enableStrictParsing' => true,
            'showScriptName' => false,
            'rules' => [

                '<controller:\w+>/<action:\w+>/<page:\d+>' => '<controller>/<action>',

                [
                    'class' => 'yii\rest\UrlRule',
                    'controller' => ['v1/users','v1/default', 'v1/tixian'],
                    'extraPatterns' => [
                        'POST login'            => 'login',
                        'POST logout'           => 'logout',
                        'POST search'           => 'search',
                        'POST index'            => 'index',
                        'POST editor'           => 'editor',
                        'POST realname'         => 'realname',
                        'POST attention'        => 'attention',
                        'POST addattention'     => 'addattention',
                        'POST fan'              => 'fan',
                        'POST abolishattention' => 'abolishattention',
                        'POST userinfor'        => 'userinfor',
                        'POST qianming'         => 'qianming',
                        'POST list'             => 'list',
                        'POST listuser'         => 'listuser',
                        'POST createlive'       => 'createlive',
                        'POST zhibolist'        => 'zhibolist',
                        'POST roomid'           => 'roomid',
                        'POST signature'        => 'signature',
                        'POST looknums'         => 'looknums',
                        'POST likes'            => 'likes',
                        'POST isattention'      => 'isattention',
                        'POST verification'     => 'verification',
                        'POST tuichu'           => 'tuichu',
                        'POST addzhiboinfor'    => 'addzhiboinfor',
                        'POST goroom'           => 'goroom',
                        'POST tuichuroom'       => 'tuichuroom',
                        'POST navbar'           => 'navbar',
                        'POST taglist'          => 'taglist',
                        'POST histoylist'       => 'histoylist',
                        'POST savevideo'        => 'savevideo',
                        'POST applyanchor'      => 'applyanchor',
                        'POST deletehistory'    => 'deletehistory',
                        'POST pay'              => 'pay',
                        'POST drow'             => 'drow',
                        'POST sendgift'         => 'sendgift',
                        'POST fankui'           => 'fankui',
                        'GET ceshi'            => 'ceshi',
                        'GET bofangqi'          => 'bofangqi',
                        'GET mp4player'          => 'mp4player',

                        'GET index'          => 'index',
                        'POST tixian'          => 'tixian',
                        'POST money'          => 'money',
                        'POST tixianverify'          => 'tixianverify',

//                        'GET duanxin' => 'duanxin',

                    ]
                ],
            ]
        ],


    ],
    'params' => $params,
];
